<?php
class MainController extends CController {
	public function filters() {
		return array (
			
			'accessControl'  // perform access control for CRUD operations
		);
	}
	public function accessRules() {
		return array (
			
			array (
				
				'allow', 
				'users' => array (
					
					'@' 
				) 
			), 
			array (
				
				'deny',  // deny all users
				'users' => array (
					
					'*' 
				), 
				'message' => '无权访问' 
			) 
		);
	}
	
	public function actionIndex() {
		$smarty = Yii::app ()->smarty;
		$smarty->display ( 'main/index.html' );
	}
	
	public function actionMiddle() {
		$smarty = Yii::app ()->smarty;
		$smarty->display ( 'main/middle.html' );
	}
	
	public function actionTop() {
		$smarty = Yii::app ()->smarty;
		$smarty->display ( 'main/header.html' );
	}
	public function actionBody() {
		$smarty = Yii::app ()->smarty;
		$smarty->display ( 'main/system.html' );
	}
	public function actionLeft() {
		$smarty = Yii::app ()->smarty;
		$purview = new Purview ( );
		$lists = $purview->getPurview ();
		$fa_lists = $lists;
		foreach ( $lists as $key => $v ) {
			$lists [$key] ['child'] = $purview->getPurByPid ( $v ['id'] );
		}
		$uid = Yii::app ()->user->id;
		
		if ($uid != 1) {
			$userpur = new UserPur ( );
			$ret = $userpur->getUserPurByUid ( $uid );
			foreach ( $lists as $key => $values ) {
				foreach ( $values ['child'] as $key1 => $v ) {
					foreach ( $ret as $v1 ) {
						if ($v ['id'] == $v1 ['purid']) {
							$arr [$key] ['id'] = $values ['id'];
							$arr [$key] ['title'] = $values ['title'];
							$arr [$key] ['path'] = $values ['path'];
							$arr [$key] ['pid'] = $values ['pid'];
							$arr [$key] ['orders'] = $values ['orders'];
							$arr [$key] ['state'] = $values ['state'];
							$arr [$key] ['child'] [] = $values ['child'] [$key1];
						}
					}
				}
			}
		}
		if(isset($arr) && !empty($arr)){
			$lists = $arr;
		}
		$smarty->assign ( "left", $lists );
		$smarty->display ( 'main/left.html' );
	}
}
?>